import request from '@/utils/request'
import type { AddPatient } from '@/types/user'
export const loginAPI = (mobile: string, password: string) => {
  return request({
    url: 'login/password',
    method: 'post',
    data: {
      mobile,
      password
    }
  })
}

export const sendCodeAPI = (mobile: string, type = 'login') => {
  return request({ url: 'code', params: { mobile, type } })
}

export const loginByCodeAPI = (mobile: string, code: string) => {
  return request({ url: 'login', method: 'post', data: { mobile, code } })
}

export const getUserInfoAPI = () => {
  return request({ url: 'patient/myUser' })
}

export const getPatientsAPI = () => {
  return request({ url: 'patient/mylist' })
}
/** 添加患者 */
export const addPatientAPI = (patient: AddPatient) => {
  return request({ url: '/patient/add', method: 'POST', data: patient })
}
/** 编辑患者 */
export const editPatientAPI = (patient: AddPatient) => {
  return request({ url: '/patient/update', method: 'PUT', data: patient })
}
/** 根据id，删除患者 */
export const delPatientAPI = (id: string) => {
  return request({ url: `/patient/del/${id}`, method: 'DELETE' })
}
// 2.2 定义患者详情查询API
/** 查询患者详情 */
export const getPatientDetail = (id: string) => {
  return request({ url: `/patient/info/${id}` })
}